﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.Configuration.Xml;
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using YF.NLOG;

namespace ThermoGroupSample
{
    public class XmlConfigManager
    {
        public static readonly string CONFIG_FILE;
        private static IConfiguration _ConfigInstance { get; set; }
        public static IConfiguration ConfigInstance => _ConfigInstance;
        static XmlConfigManager()
        {
            try
            {
                CONFIG_FILE = Path.Combine(Directory.GetCurrentDirectory(), "SystemConfig.xml");
                if (!File.Exists(CONFIG_FILE))
                {
                    CONFIG_FILE = @"D:\3.代码\4.公司\9.封测线热像仪\ThermoGroupSample\bin\Debug\ini\SystemConfig.xml";
                }
                ConfigurationBuilder builder = new ConfigurationBuilder();
                builder.SetBasePath(Directory.GetCurrentDirectory()).AddXmlFile(CONFIG_FILE, true, true);
                _ConfigInstance = builder.Build();
            }
            catch (Exception ex)
            {
                LoggerHelper._log.Error("【配置文件加载异常异常】", ex);
            }
        }
        #region 定义变量
        #endregion
    }
}
